import request from '../../utils/request'


/**
 * 分页查询海关口岸
 * @param placeCity
 * @param placeCode
 * @param placeName
 * @param placeTransfertype
 * @param page
 * @returns {Promise.<Object>}
 */
export async function getPlaceclearanceList({placeCity, placeCode, placeName, placeTransfertype , page}) {
    return request(apiPath.basedata + "/api/placeClearance", {
        method: 'get',
        data: { placeCity, placeCode, placeName, placeTransfertype , page: page.page, size: page.size}
    });
}

/**
 * 查询所有海关口岸
 * @param placeCity
 * @param placeCode
 * @param placeName
 * @param placeTransfertype
 * @param page
 * @returns {Promise.<Object>}
 */
export async function getAllPorts({status}) {
    return request(apiPath.basedata + "/api/allPlaceClearance", {
        method: 'get',
        data: {status}
    });
}

/**
 * 查询海关口岸详情
 * @param id
 * @returns {Promise.<Object>}
 */
export async function getPlaceclearanceById({id}) {
    return request(apiPath.basedata + "/api/placeClearance/"+ id, {
        method: 'get'
    });
}


/**
 * 创建海关口岸
 * @param placeCity
 * @param placeCode
 * @param placeName
 * @param placeTransfertype
 * @param placeClearance
 * @param placeOrder
 * @param userId
 * @returns {Promise.<Object>}
 */
export async function addPlaceclearance({placeCity, placeCode, placeName, placeTransfertype, placeClearance, placeOrder, userId}) {
    userId = 1;
    let creator = userId;
    placeOrder = 1;
    placeClearance = "报关口岸";
    return request(apiPath.basedata + "/api/placeClearance", {
        method: 'post',
        data: { placeCity, placeCode, placeName, placeTransfertype, placeClearance, placeOrder, userId, creator}
    });
}


/**
 * 修改海关口岸
 * @param id
 * @param placeCity
 * @param placeCode
 * @param placeName
 * @param placeTransfertype
 * @param placeClearance
 * @param placeOrder
 * @param userId
 * @returns {Promise.<Object>}
 */
export async function updatePlaceclearance({id, placeCity, placeCode, placeName, placeTransfertype, placeOrder, userId}) {
    userId = 1;
    let updater = userId;
    placeOrder = 1;
    return request(apiPath.basedata + "/api/placeClearance", {
        method: 'put',
        data: { id, placeCity, placeCode, placeName, placeTransfertype, placeOrder, userId, updater}
    });
}

/**
 * 删除海关口岸
 * @param id
 * @returns {Promise.<Object>}
 */
export async function deletePlaceclearanceById({id}) {
    return request(apiPath.basedata + "/api/placeClearance/" + id , {
        method: 'delete'
    });
}
